import requests

from utils.logger_util import Logger

message_host_qa = "https://qa-message-inner.nucarf.tech"

class Request:
    log = Logger.getlog()

    def get(self, url, headers = None,**kwargs):
        self.log.info("发起get请求，请求地址：{}".format(url))
        self.log.info("请求参数：{}".format(kwargs))
        # 如果提供了headers，则添加到请求中
        if headers:
            if 'headers' in kwargs:
                kwargs['headers'].update(headers)
            else:
                kwargs['headers'] = headers

        r = requests.get(url, **kwargs)
        self.log.info("响应状态码：{}".format(r.status_code))
        self.log.info("响应结果：{}".format(r.text))
        return r

    def post(self, url,headers, **kwargs):
        self.log.info("发起post请求，请求地址：{}".format(url))
        self.log.info("请求参数：{}".format(kwargs))
        # 如果提供了headers，则添加到请求中
        if headers:
            if 'headers' in kwargs:
                kwargs['headers'].update(headers)
            else:
                kwargs['headers'] = headers

        r = requests.post(url, **kwargs)
        self.log.info("响应状态码：{}".format(r.status_code))
        self.log.info("响应结果：{}".format(r.text))
        return r
